package zhongbo.java.air.ingestion.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.common.config.RedisConfig;
import zhongbo.java.air.ingestion.listener.RedisSubscribeLogChanelListener;

@Configuration
@Slf4j
public class RedisListenerConfig{
    /**
     * 公共静态常量 定义频道名称
     */
    public static String FLIGHT_CHANEL ="flight_path_chanel";
    public static String IN_FLIGHT = RedisConfig.IN_FLIGHT;

    /**
     * RedisMessageListenerContainer Redis消息监听容器
     *  RedisSubscribeLogChanelListener 自定义的消息监听器
     * @param listenerContainer
     * @param logChanelListener
     */
    @Autowired
    public void configlistener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChanelListener logChanelListener){
        log.info("配置redis监听器");
        Topic LogTopic = new PatternTopic(FLIGHT_CHANEL);
        listenerContainer.addMessageListener(logChanelListener,LogTopic);
     }
}
